PREFIX = /mmc/mmca1/.system/QTDownLoad

LIBVERSION = $(shell cat zlibrary/VERSION)
LIBSOVERSION = $(shell cat zlibrary/SOVERSION)
APPVERSION = $(shell cat fbreader/VERSION)

clean:
	@make TARGET_ARCH=moto UI_TYPE=ezx clean

build:
	@make -C zlibrary/core TARGET_ARCH=moto UI_TYPE=ezx
	@make -C zlibrary/text TARGET_ARCH=moto UI_TYPE=ezx
	@make -C zlibrary/ui TARGET_ARCH=moto UI_TYPE=ezx
	@make -C fbreader TARGET_ARCH=moto UI_TYPE=ezx

install:
	@make -C zlibrary/core TARGET_ARCH=moto UI_TYPE=ezx DESTDIR=$(DESTDIR) do_install
	@make -C zlibrary/text TARGET_ARCH=moto UI_TYPE=ezx DESTDIR=$(DESTDIR) do_install
	@make -C zlibrary/ui TARGET_ARCH=moto UI_TYPE=ezx DESTDIR=$(DESTDIR) do_install
	@install ../libs/moto/libexpat.so.1.5.2 $(DESTDIR)$(PREFIX)/fbreader/lib/libexpat.so.1
	@install ../libs/moto/libbz2.so.1.0.4 $(DESTDIR)$(PREFIX)/fbreader/lib/libbz2.so.1.0
	@rm $(DESTDIR)$(PREFIX)/fbreader/lib/libzlcore.so.$(LIBSOVERSION)
	@mv $(DESTDIR)$(PREFIX)/fbreader/lib/libzlcore.so.$(LIBVERSION) $(DESTDIR)$(PREFIX)/fbreader/lib/libzlcore.so.$(LIBSOVERSION)
	@rm $(DESTDIR)$(PREFIX)/fbreader/lib/libzltext.so.$(LIBSOVERSION)
	@mv $(DESTDIR)$(PREFIX)/fbreader/lib/libzltext.so.$(LIBVERSION) $(DESTDIR)$(PREFIX)/fbreader/lib/libzltext.so.$(LIBSOVERSION)
	@make -C fbreader TARGET_ARCH=moto UI_TYPE=ezx DESTDIR=$(DESTDIR) do_install

package:
	@tar -czf FBReader-$(APPVERSION).pkg -C $(DESTDIR)$(PREFIX) .
